from iClouds.allSerializers import *
from .Serializers import *


# Create your views here.
class HelloWorld(viewsets.ModelViewSet):
    __title__ = "测试接口"
    __group__ = "tank"
    __info__ = {
        "post": "创建LOL配置基本",
    }
    __doc__ = """	
    create:
    <h4>创建LOL配置基本</h4>
    """
    http_method_names = ["post"]
    authentication_classes = []
    permission_classes = [AllPermissions]
    serializer_class = NoneSerializer
    queryset = None

    def create(self, request, *args, **kwargs):
        serializer = self.serializer_class(data=request.data)
        serializer.is_valid(raise_exception=True)

        return Response({"rescode": 200, "resmsg": "success"})


# ==================================================================
class TankUsernameListViewSet(viewsets.ModelViewSet):
    __title__ = "注册账户"
    __group__ = "Tank项目"
    __info__ = {
        "get": "查询AI爱好标签列表",
        "post": "注册游戏账户",
        "put": "编辑AI爱好标签",
        "patch": "编辑AI爱好标签",
        "delete": "移除AI爱好标签",
    }
    __doc__ = """
    create:
    <h4>注册游戏账户</h4>
    """
    http_method_names = ["post"]
    authentication_classes = []
    permission_classes = [AllPermissions]
    serializer_class = TankUsernameListSerializer
    queryset = TankUsernameList.objects.all()

    def create(self, request, *args, **kwargs):
        serializer = self.serializer_class(data=request.data)
        serializer.is_valid(raise_exception=True)
        serializer.save(current=timezone.now(), status=1, is_authenticated=1)
        return Response({"rescode": 200, "resmsg": serializer.data})
